﻿//===============================================================================
// Microsoft patterns & practices
// Composite WPF (PRISM)
//===============================================================================
// Copyright (c) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System.Windows;
using Microsoft.Practices.Composite.Logging;
using Microsoft.Practices.Composite.Modularity;
using RAD.Infrastructure;
using RAD.Modules.AD;
using RAD.Modules.Scripts;
using RAD.Modules.UI;
using Microsoft.Practices.Composite.UnityExtensions;

namespace RAD
{
    /// <summary>
    /// Класс Bootstrapper - загрузчик приложения. Предназанчен для начального конфигурирования,
    /// загрузки модулей. Подробнее в документации Prism.
    /// </summary>
    public class RATRIBootStrapper : UnityBootstrapper
    {
        private readonly EntLibLoggerAdapter _logger = new EntLibLoggerAdapter();

        /// <summary>
        /// Метод формирует объект стратической загрузки модулей
        /// </summary>
        /// <returns>Ссылка на объект StaticModuleEnumerator</returns>
        protected override IModuleEnumerator GetModuleEnumerator()
        {
            return new StaticModuleEnumerator()
                .AddModule(typeof(ADModule))
                .AddModule(typeof(ScriptsModule))
                .AddModule(typeof(UIModule));
        }

        protected override ILoggerFacade LoggerFacade
        {
            get { return _logger; }
        }


        protected override void ConfigureContainer()
        {
            Container.RegisterType<IShellView, Shell>();
            base.ConfigureContainer();
        }

        protected override DependencyObject CreateShell()
        {
            ShellPresenter presenter = Container.Resolve<ShellPresenter>();
            IShellView view = presenter.View;
            view.ShowView();
            return view as DependencyObject;
        }
    }
}
